<?php
/**
 * Suggest.php
 *
 * @copyright   2023 thingsworld.com.cn - All Rights Reserved
 * @link        http://thingsworld.com.cn/
 * @author      stiffer.chen <chenl@thingsworld.com.cn>
 * @created     2023-06-16 16:51:51
 * @modified    2023-06-16 16:51:51
 *
 */

namespace App\Models;

use App\Models\Project\Task;
use App\Models\Suggest\Resolve;

class Suggest extends BaseModel
{
    protected $table = 'suggest';
    public $timestamps = true;
    public const CREATED_AT = 'create_time';
    public const UPDATED_AT = 'update_time';

    protected $fillable = [
        'title',
        'source',
        'level',
        'project_id',
        'task_id',
        'charge_user_id',
        'create_user_id',
        'description',
        'status'
    ];

    public function resolve()
    {
        return $this->hasOne(Resolve::class, 'suggest_id');
    }

    public function project()
    {
        return $this->belongsTo(Project::class, 'project_id');
    }

    public function task()
    {
        return $this->belongsTo(Task::class, 'task_id');
    }

    public function create_user()
    {
        return $this->belongsTo(UserModel::class, 'create_user_id');
    }

    public function charge_user()
    {
        return $this->belongsTo(UserModel::class, 'charge_user_id');
    }
}